mem_event: add ref counting for free requestslots
authorOlaf Hering <olaf@aepfle.de>
Mon, 5 Sep 2011 14:10:09 +0000 (15:10 +0100)
committerOlaf Hering <olaf@aepfle.de>
Mon, 5 Sep 2011 14:10:09 +0000 (15:10 +0100)
commit46d0343de0799a1dd77fbf996e878dd6cc56826e
treec97fbe9c26bbe4aa5d3b9eadace3dbecf498cf0d
parentfdf21233645251000b1c8c9c24fb0e8cd6e2ee24
mem_event: add ref counting for free requestslots

If mem_event_check_ring() is called by many vcpus at the same time
before any of them called also mem_event_put_request(), all of the
callers must assume there are enough free slots available in the ring.

Record the number of request producers in mem_event_check_ring() to
keep track of available free slots.

Add a new mem_event_put_req_producers() function to release a request
attempt made in mem_event_check_ring(). Its required for
p2m_mem_paging_populate() because that function can only modify the
p2m type if there are free request slots. But in some cases
p2m_mem_paging_populate() does not actually have to produce another
request when it is known that the same request was already made
earlier by a different vcpu.

mem_event_check_ring() can not return a reference to a free request
slot because there could be multiple references for different vcpus
and the order of mem_event_put_request() calls is not known. As a
result, incomplete requests could be consumed by the ring user.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
xen/arch/x86/mm/mem_event.c
xen/arch/x86/mm/mem_sharing.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/mem_event.h
xen/include/xen/sched.h